by coincidence

Through an accidental simultaneous occurrence, as in By coincidence both researchers discovered the same solution. [ Mid-1600s ]
Also see: by chance